package com.xy.hms.config;

import io.swagger.models.Swagger;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @author xiaye
 * @create 2020-03-17-9:26
 */
@Configuration
@EnableSwagger2   //开启swagger2
public class SwaggerConfig {

    private static final Contact DEFAULT_CONTACT = new Contact("夏烨", "https://segmentfault.com/u/xiaye_5e702b22aea45", "1159395895@qq.com");

    //配置swagger 的 docket实例

    @Bean
    public Docket docket2(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("test");
    }
    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("xiaye")
                .select()
                //指定要扫描的包
                .apis(RequestHandlerSelectors.basePackage("com.xy.hms.controller"))
                .build();
    }

    private ApiInfo apiInfo(){
        return new ApiInfo(
                "night的swagger文档"
                , "swagger学习测试"
                , "1.0"
                , "urn:tos"
                , DEFAULT_CONTACT
                , "Apache 2.0"
                , "http://www.apache.org/licenses/LICENSE-2.0"
                , new ArrayList());

    }

}

